limsPurposeMethodEquipt.editPage = {

    getGridParam : function() {
        var _this = this;
        return {
            type : 'grid',
            id : 'lims-purpose-method-equipt-edit-list-grid',
            url : limsPurposeMethodEquipt.baseUrl + '/queries/raw',
            service : 'limsPurposeMethodEquiptServiceImpl',
            dbTable : 'T_LIMS_PURPOSE_METHOD_EQUIPT',
            columns : limsPurposeMethodEquipt.getEditListColumns(),
            onLoadSuccess : function(data) {
                if (!Gikam.isEmpty(data)) {
                    this.activeRowByIndex(0);
                } else {
                    Gikam.cleanCompData([ 'lims-purpose-method-equipt-edit-list-base-info-form' ]);
                }
            },
            onRowActive : function(index, row) {

                Gikam.getAsyncComp('lims-purpose-method-equipt-edit-list-base-info-form').done(function(form) {
                    form.refresh({
                        url : Gikam.printf(limsPurposeMethodEquipt.baseUrl + '/{id}', {
                            id : row.id
                        })
                    });
                });

            },
            toolbar : [ {
                type : 'button',
                text : 'GIKAM.BUTTON.INSERT',
                icon : 'add',
                onClick : function() {
                    Gikam.preInsert({
                        modalTitle : 'BASEMODULE.COREDATA.PJPRODUCTS.MODAL.ADD',
                        fields : limsPurposeMethodEquipt.getBaseInfoFormFields(),
                        url : limsPurposeMethodEquipt.baseUrl
                    }).done(function(id) {
                        Gikam.getComp('lims-purpose-method-equipt-edit-list-grid').refresh();
                    });
                }
            }, {
                type : 'button',
                text : 'GIKAM.BUTTON.DELETE',
                icon : 'remove-row',
                onClick : function() {
                    Gikam.getComp('lims-purpose-method-equipt-edit-list-grid').deleteRows(limsPurposeMethodEquipt.baseUrl);
                }
            } ]
        }
    },

    getBaseInfoTab : function() {
        var _this = this;
        return {
            type : 'tab',
            panels : [ {
                title : 'BASEMODULE.COREDATA.PJPRODUCTS.TAB.BASE_INFO',
                items : [ {
                    type : 'form',
                    service : 'limsPurposeMethodEquiptServiceImpl',
                    dbTable : 'T_LIMS_PURPOSE_METHOD_EQUIPT',
                    id : 'lims-purpose-method-equipt-edit-list-base-info-form',
                    fields : limsPurposeMethodEquipt.getBaseInfoFormFields(),
                    onUpdated : function() {
                        var grid = Gikam.getComp('lims-purpose-method-equipt-edit-list-grid');
                        grid.refreshRowById(grid.getActivedRow().id);
                    },
                } ]
            } ]
        }
    },

    create : function() {
        var _this = this;
        Gikam.create('layout', {
            id : 'lims-purpose-method-equipt-edit-list-layout',
            renderTo : workspace.window.$dom,
            west : {
                width : 300,
                items : [ this.getGridParam() ]
            },
            center : {
                items : [ this.getBaseInfoTab() ]
            }
        });
    },

    init : function() {
        this.create();
    }
};
